<?php defined('_JEXEC') or die('Restricted access');
/*
This file is part of "Fox Joomla Extensions".

You can redistribute it and/or modify it under the terms of the GNU General Public License
GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html

You have the freedom:
* to use this software for both commercial and non-commercial purposes
* to share, copy, distribute and install this software and charge for it if you wish.
Under the following conditions:
* You must attribute the work to the original author by leaving untouched the link "powered by",
except if you obtain a "registerd version" http://www.fox.ra.it/forum/14-licensing/151-remove-the-backlink-powered-by-fox-contact.html

Author: Demis Palma
Documentation at http://www.fox.ra.it/forum/2-documentation.html
*/

class FoxEmailHelper
{
	protected $Params;

	public function __construct(&$params)
	{
		$this->Params = $params;
	}

	public function convert($data)
	{
		$type = $data->select;
		return $this->{$data->select}($data);
	}

	public function submitter($data)
	{
		$application = JFactory::getApplication();
		$name = "_" . md5($this->Params->get("sender0") . $application->cid . $application->mid);
		$name = JRequest::getVar($name, NULL, "POST");
		$address = "_" . md5($this->Params->get("sender1") . $application->cid . $application->mid);
		$address = JRequest::getVar($address, NULL, "POST");
		return array($address, $name);
	}

	public function admin($data)
	{
		$application = JFactory::getApplication();
		$name = $application->getCfg("fromname");
		$address = $application->getCfg("mailfrom");
		return array($address, $name);
	}

	public function custom($data)
	{
		return array($data->email, $data->name);
	}
}


